function VerifyUserName(){
	var UserName = $("#UserName").val();

	$.get("Register/VerifyUser/UserName/" + UserName, function(result){
		var result = result.replace("\n","").replace(/(^\s*)|(\s*$)/g, "");
			if(result == "True"){
				alert("用户名已经被注册~");
				$("#UserName").val("")
			}
			else{
				//alert("用户名已经被注册~");
			}
		});
}

function VerifyEmail(){
	var Email = $("#Email").val();

	 if (Email != "" && IsEmail(Email)) {
		$.get("Register/VerifyUser/Email/" + Email, function(result){
		var result = result.replace("\n","").replace(/(^\s*)|(\s*$)/g, "");
			if(result == "True"){
				alert("邮箱已经被注册~");
				$("#Email").val("");
			}
			else{
				//alert("用户名已经被注册~");
			}
		});
	 }
	else{
		alert("请填写正确的邮箱地址");
		$("#Email").val("");
	}
	
}

function VerifyPassword(){
	var password = $("#Password").val();
	var Confirmpassword = $("#ConfirmPassword").val();

	if(password == ""){
		alert("密码不能为空");
		return;
	}

	if(password != Confirmpassword)
	{
		alert("密码两次输入不一致");
		$("#ConfirmPassword").val("");
	}
}

function Formsubmit(Form){
	var password = $("#Password").val();
	var Confirmpassword = $("#ConfirmPassword").val();
	var Email = $("#Email").val();
	var UserName = $("#UserName").val();

	if(password != "" &&Confirmpassword != "" && password == Confirmpassword && UserName != "" && Email != ""){
		setTimeout(function () {
			Form.submit();
			return true;
		}, 100);
	}
	else{
		return false;
	}
}

function IsEmail(email) {
    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return regex.test(email);
}